package edu.um.token;

import edu.um.token.exception.InvalidTokenException;

public class Token {
  private final String value;

  private final TokenKind kind;

  private final int column;

  private final int line;

  public Token(String value, int column, int line) throws InvalidTokenException {
    kind = TokenKind.find(value);
    if (kind == null) {
      throw new InvalidTokenException(line, column, value);
    }
    this.value = value;
    this.column = column;
    this.line = line;
  }

  public String getValue() {
    return value;
  }

  public TokenKind getKind() {
    return kind;
  }

  public int getColumn() {
    return column;
  }

  public int getLine() {
    return line;
  }

  @Override
  public String toString() {
    return kind.name() + ": " + value + " at " + line + "-" + column;
  }

}
